package com.gitee.wsl.mathematics.matrix.mat

import kotlin.math.pow

/**
 * 范德蒙矩阵
 */
class VandermondeMatrix(rowCount: Int,
                        private val elements: List<Double>):FunMatrix(rowCount,elements.size,
    valueFun = {i,j-> elements[i].pow(j) }) {

    //override val rank by lazy { min(row, elements.toSet().size) }
    //override val trace by lazy { traceValue() }

   /*
   override val det by lazy {
        when {
            row != column -> null
            row != rank   -> .0
            row == 1      -> elements.first()
            else          -> elements.indices.reversed().fold(1.0) { acc, i ->
                acc * (i - 1 downTo 0).fold(1.0) { sum, j ->
                    sum * (elements[i] - (elements.getOrNull(j) ?: .0))
                }
            }
        }
    }
    */
}